package com.bdqn.service.impl;

import com.bdqn.mapper.SupplierMapper;
import com.bdqn.mapper.SysUserMapper;
import com.bdqn.pojo.Supplier;
import com.bdqn.service.SupplierService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * SupplierServiceImpl
 *
 * @aurhor Administrator  whs
 * @since 2024/8/5
 */
@Transactional // 为该类的所有业务方法统一添加事务处理
@Service("supplierService")
public class SupplierServiceImpl implements SupplierService {

    /**
     * 引入数据访问层
     */
    @Resource
    private SupplierMapper supplierMapper;

    public SupplierMapper getSupplierMapper() {
        return supplierMapper;
    }

    public void setSupplierMapper(SupplierMapper supplierMapper) {
        this.supplierMapper = supplierMapper;
    }


    /**
     * 实现分页查询功能按创建时间降序排序
     *
     * @param querySupCode 供货商编码
     * @param querySupName 供货商名称
     * @param pageIndex    页码
     * @param pageSize     每页显示几条数据
     * @return
     */
    @Override
    public List<Supplier> selectSupplierPageBeginLimitList(String querySupCode, String querySupName, Integer pageIndex, Integer pageSize) {
        return supplierMapper.selectSupplierPageBeginLimitList(querySupCode, querySupName, pageIndex, pageSize);
    }

    /**
     * 查询供货商表的总记录数
     *
     * @param supName 供货商名称
     * @param supCode 供货商编码
     * @return
     */
    @Override
    public int count(String supName, String supCode) {
        return supplierMapper.count(supName, supCode);
    }

    /**
     * 根据id查看供货商信息
     *
     * @param id
     * @return
     */
    @Override
    public Supplier selectSupplierById(Integer id) {
        return supplierMapper.selectSupplierById(id);
    }

    /**
     * 供货商模块修改
     *
     * @param supplier
     * @return
     */
    @Override
    public boolean update(Supplier supplier) {
        return supplierMapper.update(supplier)==1;
    }

    /**
     * 添加供货商
     *
     * @param supplier
     * @return
     */
    @Override
    public boolean addSupplier(Supplier supplier) {
        return supplierMapper.addSupplier(supplier) == 1;
    }

}
